<?php

namespace Admin\Controller;

class BoxmanController extends AdminController {

    public function index() {

        $keywords = I('keywords');
        if ($keywords) {
            $where['boxman_phone'] = array('like', "%{$keywords}%");
            $this->assign('keywords', $keywords);
        }

        $M = M('Boxman');
        $field = '*';
        $order = "boxman_id desc";
        $list = $this->lists($M, $where, $order, $field);

        $this->assign('_list', $list);
        $this->display();
    }

    public function changestatus() {
        $uid = I('id', 0, 'intval');

        $status = I('status', 0, 'intval');
        if ($uid) {
            $data['boxman_status'] = $status;
            $res = M('Boxman')->where(array('boxman_id' => $uid))->save($data);
        }

        if ($res) {
            $this->success('操作成功');
        } else {
            $this->error('操作失败');
        }
    }

}
